/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vcms.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import com.vportal.portlet.vcms.model.VcmsThread;
import com.vportal.portlet.vcms.model.VcmsThreadModel;
import com.vportal.portlet.vcms.model.VcmsThreadSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the VcmsThread service. Represents a row in the &quot;VcmsThread&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vcms.model.VcmsThreadModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link VcmsThreadImpl}.
 * </p>
 *
 * @author hai
 * @see VcmsThreadImpl
 * @see com.vportal.portlet.vcms.model.VcmsThread
 * @see com.vportal.portlet.vcms.model.VcmsThreadModel
 * @generated
 */
@JSON(strict = true)
public class VcmsThreadModelImpl extends BaseModelImpl<VcmsThread>
	implements VcmsThreadModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a vcms thread model instance should use the {@link com.vportal.portlet.vcms.model.VcmsThread} interface instead.
	 */
	public static final String TABLE_NAME = "VcmsThread";
	public static final Object[][] TABLE_COLUMNS = {
			{ "threadId", Types.VARCHAR },
			{ "groupId", Types.BIGINT },
			{ "companyId", Types.BIGINT },
			{ "createdDate", Types.TIMESTAMP },
			{ "createdByUser", Types.VARCHAR },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "modifiedByUser", Types.VARCHAR },
			{ "title", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "hasImage", Types.BOOLEAN },
			{ "image", Types.VARCHAR },
			{ "language", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table VcmsThread (threadId VARCHAR(75) not null primary key,groupId LONG,companyId LONG,createdDate DATE null,createdByUser VARCHAR(75) null,modifiedDate DATE null,modifiedByUser VARCHAR(75) null,title VARCHAR(500) null,description VARCHAR(1000) null,hasImage BOOLEAN,image VARCHAR(75) null,language VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table VcmsThread";
	public static final String ORDER_BY_JPQL = " ORDER BY vcmsThread.createdDate DESC";
	public static final String ORDER_BY_SQL = " ORDER BY VcmsThread.createdDate DESC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vcms.model.VcmsThread"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vcms.model.VcmsThread"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vcms.model.VcmsThread"),
			true);
	public static long GROUPID_COLUMN_BITMASK = 1L;
	public static long LANGUAGE_COLUMN_BITMASK = 2L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static VcmsThread toModel(VcmsThreadSoap soapModel) {
		VcmsThread model = new VcmsThreadImpl();

		model.setThreadId(soapModel.getThreadId());
		model.setGroupId(soapModel.getGroupId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setCreatedDate(soapModel.getCreatedDate());
		model.setCreatedByUser(soapModel.getCreatedByUser());
		model.setModifiedDate(soapModel.getModifiedDate());
		model.setModifiedByUser(soapModel.getModifiedByUser());
		model.setTitle(soapModel.getTitle());
		model.setDescription(soapModel.getDescription());
		model.setHasImage(soapModel.getHasImage());
		model.setImage(soapModel.getImage());
		model.setLanguage(soapModel.getLanguage());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<VcmsThread> toModels(VcmsThreadSoap[] soapModels) {
		List<VcmsThread> models = new ArrayList<VcmsThread>(soapModels.length);

		for (VcmsThreadSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vcms.model.VcmsThread"));

	public VcmsThreadModelImpl() {
	}

	public String getPrimaryKey() {
		return _threadId;
	}

	public void setPrimaryKey(String primaryKey) {
		setThreadId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return _threadId;
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey((String)primaryKeyObj);
	}

	public Class<?> getModelClass() {
		return VcmsThread.class;
	}

	public String getModelClassName() {
		return VcmsThread.class.getName();
	}

	@JSON
	public String getThreadId() {
		if (_threadId == null) {
			return StringPool.BLANK;
		}
		else {
			return _threadId;
		}
	}

	public void setThreadId(String threadId) {
		_threadId = threadId;
	}

	@JSON
	public long getGroupId() {
		return _groupId;
	}

	public void setGroupId(long groupId) {
		_columnBitmask |= GROUPID_COLUMN_BITMASK;

		if (!_setOriginalGroupId) {
			_setOriginalGroupId = true;

			_originalGroupId = _groupId;
		}

		_groupId = groupId;
	}

	public long getOriginalGroupId() {
		return _originalGroupId;
	}

	@JSON
	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	@JSON
	public Date getCreatedDate() {
		return _createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		_columnBitmask = -1L;

		_createdDate = createdDate;
	}

	@JSON
	public String getCreatedByUser() {
		if (_createdByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _createdByUser;
		}
	}

	public void setCreatedByUser(String createdByUser) {
		_createdByUser = createdByUser;
	}

	@JSON
	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	@JSON
	public String getModifiedByUser() {
		if (_modifiedByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _modifiedByUser;
		}
	}

	public void setModifiedByUser(String modifiedByUser) {
		_modifiedByUser = modifiedByUser;
	}

	@JSON
	public String getTitle() {
		if (_title == null) {
			return StringPool.BLANK;
		}
		else {
			return _title;
		}
	}

	public void setTitle(String title) {
		_title = title;
	}

	@JSON
	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	@JSON
	public boolean getHasImage() {
		return _hasImage;
	}

	public boolean isHasImage() {
		return _hasImage;
	}

	public void setHasImage(boolean hasImage) {
		_hasImage = hasImage;
	}

	@JSON
	public String getImage() {
		if (_image == null) {
			return StringPool.BLANK;
		}
		else {
			return _image;
		}
	}

	public void setImage(String image) {
		_image = image;
	}

	@JSON
	public String getLanguage() {
		if (_language == null) {
			return StringPool.BLANK;
		}
		else {
			return _language;
		}
	}

	public void setLanguage(String language) {
		_columnBitmask |= LANGUAGE_COLUMN_BITMASK;

		if (_originalLanguage == null) {
			_originalLanguage = _language;
		}

		_language = language;
	}

	public String getOriginalLanguage() {
		return GetterUtil.getString(_originalLanguage);
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public VcmsThread toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (VcmsThread)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		VcmsThreadImpl vcmsThreadImpl = new VcmsThreadImpl();

		vcmsThreadImpl.setThreadId(getThreadId());
		vcmsThreadImpl.setGroupId(getGroupId());
		vcmsThreadImpl.setCompanyId(getCompanyId());
		vcmsThreadImpl.setCreatedDate(getCreatedDate());
		vcmsThreadImpl.setCreatedByUser(getCreatedByUser());
		vcmsThreadImpl.setModifiedDate(getModifiedDate());
		vcmsThreadImpl.setModifiedByUser(getModifiedByUser());
		vcmsThreadImpl.setTitle(getTitle());
		vcmsThreadImpl.setDescription(getDescription());
		vcmsThreadImpl.setHasImage(getHasImage());
		vcmsThreadImpl.setImage(getImage());
		vcmsThreadImpl.setLanguage(getLanguage());

		vcmsThreadImpl.resetOriginalValues();

		return vcmsThreadImpl;
	}

	public int compareTo(VcmsThread vcmsThread) {
		int value = 0;

		value = DateUtil.compareTo(getCreatedDate(), vcmsThread.getCreatedDate());

		value = value * -1;

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		VcmsThread vcmsThread = null;

		try {
			vcmsThread = (VcmsThread)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		String primaryKey = vcmsThread.getPrimaryKey();

		if (getPrimaryKey().equals(primaryKey)) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return getPrimaryKey().hashCode();
	}

	@Override
	public void resetOriginalValues() {
		VcmsThreadModelImpl vcmsThreadModelImpl = this;

		vcmsThreadModelImpl._originalGroupId = vcmsThreadModelImpl._groupId;

		vcmsThreadModelImpl._setOriginalGroupId = false;

		vcmsThreadModelImpl._originalLanguage = vcmsThreadModelImpl._language;

		vcmsThreadModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<VcmsThread> toCacheModel() {
		VcmsThreadCacheModel vcmsThreadCacheModel = new VcmsThreadCacheModel();

		vcmsThreadCacheModel.threadId = getThreadId();

		String threadId = vcmsThreadCacheModel.threadId;

		if ((threadId != null) && (threadId.length() == 0)) {
			vcmsThreadCacheModel.threadId = null;
		}

		vcmsThreadCacheModel.groupId = getGroupId();

		vcmsThreadCacheModel.companyId = getCompanyId();

		Date createdDate = getCreatedDate();

		if (createdDate != null) {
			vcmsThreadCacheModel.createdDate = createdDate.getTime();
		}
		else {
			vcmsThreadCacheModel.createdDate = Long.MIN_VALUE;
		}

		vcmsThreadCacheModel.createdByUser = getCreatedByUser();

		String createdByUser = vcmsThreadCacheModel.createdByUser;

		if ((createdByUser != null) && (createdByUser.length() == 0)) {
			vcmsThreadCacheModel.createdByUser = null;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			vcmsThreadCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			vcmsThreadCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		vcmsThreadCacheModel.modifiedByUser = getModifiedByUser();

		String modifiedByUser = vcmsThreadCacheModel.modifiedByUser;

		if ((modifiedByUser != null) && (modifiedByUser.length() == 0)) {
			vcmsThreadCacheModel.modifiedByUser = null;
		}

		vcmsThreadCacheModel.title = getTitle();

		String title = vcmsThreadCacheModel.title;

		if ((title != null) && (title.length() == 0)) {
			vcmsThreadCacheModel.title = null;
		}

		vcmsThreadCacheModel.description = getDescription();

		String description = vcmsThreadCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			vcmsThreadCacheModel.description = null;
		}

		vcmsThreadCacheModel.hasImage = getHasImage();

		vcmsThreadCacheModel.image = getImage();

		String image = vcmsThreadCacheModel.image;

		if ((image != null) && (image.length() == 0)) {
			vcmsThreadCacheModel.image = null;
		}

		vcmsThreadCacheModel.language = getLanguage();

		String language = vcmsThreadCacheModel.language;

		if ((language != null) && (language.length() == 0)) {
			vcmsThreadCacheModel.language = null;
		}

		return vcmsThreadCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(25);

		sb.append("{threadId=");
		sb.append(getThreadId());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", createdDate=");
		sb.append(getCreatedDate());
		sb.append(", createdByUser=");
		sb.append(getCreatedByUser());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", modifiedByUser=");
		sb.append(getModifiedByUser());
		sb.append(", title=");
		sb.append(getTitle());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", hasImage=");
		sb.append(getHasImage());
		sb.append(", image=");
		sb.append(getImage());
		sb.append(", language=");
		sb.append(getLanguage());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(40);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vcms.model.VcmsThread");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>threadId</column-name><column-value><![CDATA[");
		sb.append(getThreadId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdDate</column-name><column-value><![CDATA[");
		sb.append(getCreatedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdByUser</column-name><column-value><![CDATA[");
		sb.append(getCreatedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedByUser</column-name><column-value><![CDATA[");
		sb.append(getModifiedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>title</column-name><column-value><![CDATA[");
		sb.append(getTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>hasImage</column-name><column-value><![CDATA[");
		sb.append(getHasImage());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>image</column-name><column-value><![CDATA[");
		sb.append(getImage());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>language</column-name><column-value><![CDATA[");
		sb.append(getLanguage());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = VcmsThread.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			VcmsThread.class
		};
	private String _threadId;
	private long _groupId;
	private long _originalGroupId;
	private boolean _setOriginalGroupId;
	private long _companyId;
	private Date _createdDate;
	private String _createdByUser;
	private Date _modifiedDate;
	private String _modifiedByUser;
	private String _title;
	private String _description;
	private boolean _hasImage;
	private String _image;
	private String _language;
	private String _originalLanguage;
	private long _columnBitmask;
	private VcmsThread _escapedModelProxy;
}